//获取输入框
var inputs = document.querySelectorAll('input');
//获取登陆按钮
var loginBtn = document.querySelector('button');

//给登录按钮 绑定点击事件
loginBtn.onclick = () => {
    //发起登陆请求
    axios.post('/user/login', { phone: inputs[0].value, pass: inputs[1].value }).then((res) => {
        if (res.data.code == 200) {
            localStorage.setItem('token', res.data.token);
            console.log(res.data.token);
            localStorage.setItem('userinfo', JSON.stringify(res.data.userinfo))
            location.href = './index.html'
            alert('登录成功！')
        } else {
            alert('登陆失败!')

        }
    })
}